package co.baiku.boot.im.tencent.request;

import co.baiku.boot.common.tools.RandomTools;
import co.baiku.boot.common.tools.StringTools;
import co.baiku.boot.im.tencent.request.data.TencentImRequestData;

/**
 * 最高调用频率 100次/秒
 */
public class TencentImRequest {

    public TencentImRequest() {
        this.random = System.currentTimeMillis() + "" + RandomTools.number(100000, 999999) + "" + (System.currentTimeMillis() + RandomTools.number(1000, 9999));
    }

    public TencentImRequest(Long sdkappid, TentcentImAPI api, String identifier, TencentImRequestData data) {
        this();
        this.sdkappid = sdkappid;
        this.api = api;
        this.identifier = identifier;
        this.data = data;
    }

    private String host = "https://console.tim.qq.com";

    /**
     * 请求接口
     */
    private TentcentImAPI api;
    /**
     * 创建应用时云通信 IM 控制台分配的 SDKAppID
     */
    private Long sdkappid;
    /**
     * 帐号
     */
    private String identifier;
    /**
     * 帐号生成的签名,参见 <a href='https://cloud.tencent.com/document/product/269/32688'>UserSig 后台 API</a>
     */
    private String usersig;
    /**
     * 随机的32位无符号整数
     */
    private String random;

    private String contenttype = "json";

    public String queryString() {
        return StringTools.format("?sdkappid={0}&identifier={1}&usersig={2}&random={3}&contenttype=json", sdkappid+"", identifier, usersig, random);
    }

    private TencentImRequestData data;


    public String getContenttype() {
        return contenttype;
    }

    public void setContenttype(String contenttype) {
        this.contenttype = contenttype;
    }

    public TencentImRequestData getData() {
        return data;
    }

    public void setData(TencentImRequestData data) {
        this.data = data;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public TentcentImAPI getApi() {
        return api;
    }

    public void setApi(TentcentImAPI api) {
        this.api = api;
    }

    public Long getSdkappid() {
        return sdkappid;
    }

    public void setSdkappid(Long sdkappid) {
        this.sdkappid = sdkappid;
    }

    public String getIdentifier() {
        return identifier;
    }

    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }

    public String getUsersig() {
        return usersig;
    }

    public void setUsersig(String usersig) {
        this.usersig = usersig;
    }

    public String getRandom() {
        return random;
    }

    public void setRandom(String random) {
        this.random = random;
    }
}
